package wwl.lsf.hellospringboot.test.nio.传统的阻塞;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {

  public static void main(String[] args) throws IOException {

    ServerSocket ss = new ServerSocket(9999);

    while (true) {
      Socket accept = ss.accept();

      InputStream inputStream = accept.getInputStream();

      byte[] bytes = new byte[10];
      int read = inputStream.read(bytes);

      String hostAddress = accept.getInetAddress().getHostAddress();

      System.out.println("hostAddress = " + hostAddress+"说:"+new String(bytes).trim());

      OutputStream outputStream = accept.getOutputStream();
      outputStream.write("没钱".getBytes());

      accept.close();
    }
  }

}
